<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>提款</title>
    <link rel="stylesheet" type="text/css" href="/css/basic.css"/>
    <link rel="stylesheet" type="text/css" href="/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="/css/center.css"/>
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css"/>
</head>

<body>
<div th:fragment="withdrawal">

    <div class="manage_box_one" id="bindingbankdiv" th:if="${ #lists.isEmpty(bankList)}">
        <div>
            <span><img src="/images/visa.png"></span>
            <p>阁下还未<a id="bindingBank" href="/bankList" style="color:red;">绑定银行卡 !</a></p>
        </div>
    </div>


    <div class="tk_nr" th:if="${ not #lists.isEmpty(bankList)}">
        <div class="tk_title" style="padding-top:10px; height:40px;">
            <h3>提款</h3>
            <span>通常您的提款只需3-15分钟即可到账，若超过30分钟仍未到账，请联系在线客服核查。</span>
        </div>
        <div class="tk_box" style="font-weight: bold; margin-left: 30px;">
            <form id="withdrawalFrom">
                <div class="tk_jr">
                    <span class="text">提款金额：</span>
                    <span class="input">
                        <input id="withdrawalMoney" name="withdrawalAmount" type="number" placeholder="金额"
                               class="r_inptut inputwd300 deposit-money">
                    </span>
                </div>
                <div class="tk_ts" style="margin-top:0px; margin-left:120px;">
                    <span id="withdrawalMoney_tips" class="text">最低提款值金额不能低于100元</span>
                </div>

                <div class="tk_yh clear">
                    <span class="text">选择银行：</span>
                    <span class="radio">
                        <label th:class="${bankStat.first}? 'on'" style="border: 1px solid #c8cccf; width: 300px"
                               th:each="item,bankStat:${bankList}">
                             <input type="radio" name="bankId" th:value="${item.bankId}" th:checked="${bankStat.first}">
                             <b style="margin-left:20px;"
                                th:text="${item.userBankName} +' **** **** **** '+ ${item.userBankNo}"></b>
                        </label>
                    </span>
                </div>
                <div>
                    <button type="button" id="withdrawal_submit" class="as_but inputwd300">提交提款</button>
                </div>
            </form>

            <link rel="stylesheet" href="/js/loading/loading.css">
            <script src="/js/loading/loading.js"></script>
            <script>
                var jiuXiuLoad = new Loading();
                jiuXiuLoad.init();

                $(".radio label").click(function () {
                    $(this).find('input').attr("checked", 'checked').parent().siblings().find('input').attr("checked", false);
                    $(this).find('input').parent().siblings().removeClass("on");
                    $(this).addClass('on');
                });

                $("#withdrawal_submit").click(function () {
                    var inputObj = $("#withdrawalMoney");
                    if (inputObj.val().length == 0) {
                        alertWorning('请输入你的提款金额!');
                        return;
                    }
                    if (inputObj.val() < 100) {
                        alertWorning('最低提款值金额不能低于100元');
                        return;
                    }

                    jiuXiuLoad.start();
                    $.ajax({
                        method: "POST",
                        url: "/api/withdrawalSubmit",
                        data: $("#withdrawalFrom").serializeArray(),
                        dataType: "json"
                    }).done(function (msg) {
                        jiuXiuLoad.stop();
                        if (msg.status == 'success') {
                            alertGood('提交成功!');
                            document.getElementById("withdrawalFrom").reset();
                        } else {
                            alertWorning(msg.data)
                        }
                    });
                })

            </script>
        </div>
    </div>
</div>
</body>
</html>